// 引入路由模块
const { Router } = require('express')
// 创建一个路由实例
const router = new Router()

// 引入用户信息表模型
const userImformationModel = require('../../model/userImformation')

// 引入写好的操作对象方法
const {findOneDoc} = require('../../utils/DB/controlDB')

router.get('/userInfo',(request, response)=>{
    const attachOption = {
        _id:0,
        count:1,
        email:1,
        sex:1,
        signature:1,
        imgUrl:1,
        roles:1,
        nickname:1,
        boss:1
    }

    if (request.get('Referer') == 'http://localhost:9000/') attachOption.boss = 1;

    const { _id } = request.query
    const docObJ = {
        model: userImformationModel,
        option: {
            _id
        },
        attachOption,
        callback: function (data) {
            response.send(JSON.stringify(data))
        }
    }
    findOneDoc(docObJ)
})

module.exports = router
